package com.dsp.order.dao;

import com.dsp.order.entity.Order;
import org.springframework.data.jdbc.repository.query.Modifying;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

public interface OrderDao extends PagingAndSortingRepository<Order,Long> {

    @Query("select * from `order` where name= :name and enable = 1")
    Order findByName(String name);

    @Query("select id from `order` where name= :name and enable = 1")
    Long confirm(String name);

    @Modifying
    @Query("update `order` set enable = -1 where name= :name and enable = 1")
    int cancel(String name);
}